var mess = [];
header.init('账户管理');
footer.init();
app.ajax(
	'/Member/Shop/cash_withdrawal_account_list',
	null,
	function(res){
		if(res.code == 200){
			app.tpl($('.manAc'),'tpl-manAc',res);
				var list = res.list;
					for(var i=0;i<list.length;i++){
						var data={
							id : list[i].id,
							account_name : list[i].account_name,
							account_number : list[i].account_number,
							account_type  : list[i].account_type,
							account_bank_addr : list[i].account_bank_addr,
							isdefault : list[i].is_default,
							code      : list[i].code
						}
						mess.push(data);
					}
		}else{
			layer.msg('网络繁忙，请稍候再试');
		}
	}
);
window.onload = function(){
	$('body').on('click','.man-Account .dele',function(){//删除
		var ids = $(this).parents('.man-fun').attr('data-id');
		var data={
			id : ids
		};
		var t=$(this);
		layer.open({
			content:'确定要删除该账户吗？',
			btn:['确定','取消'],
			shadeClose:false,
			yes:function(index){
				layer.close(index);
				app.ajax(
					'/Member/Shop/cash_withdrawal_account_delete',
					{
						id : ids	
					},function(res){
						if(res.code == 200){
							layer.msg('删除成功');
							t.parents('.man-Account').remove();
						}
				});
			}
		});
		
	});
	
	$('body').on('click','.man-Account .edit',function(){
		var index = $(this).parents('.man-Account').index('.manAc .man-Account');
		var data = mess[index];
		app.open('shop.bindAccount.html','shop_bindAccount',{type:1,data1:data},window.location.href,document.body.scrollTop);
	});
	
	$('body').on('click','.add',function(){
		app.open('shop.bindAccount.html','shop_bindAccount',{type:2},window.location.href,document.body.scrollTop);
	});

}
